function [] = DrawMEStimators()
x=sort(randn(1000,1));
r=x;

plot(x,bisquare(r));
title('bisquare');
figure

plot(x,andrews(r));
title('andrews');
figure

plot(x,cauchy(r));
title('cauchy');
figure

plot(x,fair(r));
title('fair');
figure


plot(x,huber(r));
title('huber');
figure


plot(x,logistic(r));
title('logistic');
figure

plot(x,ols(r));
title('ols');
figure


plot(x,talwar(r));
title('talwar');
figure


plot(x,welsch(r));
title('welsch');
figure

end

function w = bisquare(r)
t= 4.685;
r=r/t;
w = (abs(r)<1) .* (1 - (r/1).^2).^2;
w(r<eps,1)=0;
end

function w = andrews(r)
t = 1.339;
r=r/t;
r = max(sqrt(eps(class(r))), abs(r));
w = (abs(r)<pi) .* sin(r) ./ r;
end


function w = cauchy(r)
t= 2.385;
r=r/t;
w = 1 ./ (1 + r.^2);
end

function w = fair(r)
t = 1.400;
r=r/t;
w = 1 ./ (1 + abs(r));
end

function w = huber(r)
t = 1.345;
r=r/t;
w = 1 ./ max(1, abs(r));
end

function w = logistic(r)
t = 1.205;
r=r/t;
r = max(sqrt(eps(class(r))), abs(r));
w = tanh(r) ./ r;
end

function w = ols(r)
t = 1;
r=r/t;
w = ones(size(r));
end

function w = talwar(r)
t = 2.795;
r=r/t;
w = 1 * (abs(r)<1);
end

function w = welsch(r)
t = 2.985;
r=r/t;
w = exp(-(r.^2));
end